import request from '@/utils/request2'

export function getRoutes() {
  return request({
    url: '/sys/role/getRoles',
    method: 'get'
  })
}

export function getRoles() {
  return request({
    url: '/sys/role/getRoles',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/sys/role/add',
    method: 'post',
    data
  })
}

export function updateRole(data) {
  return request({
    url: '/sys/role/edit',
    method: 'post',
    data
  })
}

export function deleteRole(data) {
  return request({
    url: `/sys/role/delete`,
    method: 'post',
    data
  })
}
export function fetchRoleList(query) {
  return request({
    url: '/sys/role/list',
    method: 'get',
    baseURL: process.env.VUE_APP_BASE_API2,
    params: query
  })
}

export function fetchMenus(query) {
  return request({
    url: '/sys/role/usermenus',
    method: 'get',
    baseURL: process.env.VUE_APP_BASE_API2,
    params: query
  })
}
export function fetchMenuIdsByUser(query) {
  return request({
    url: '/sys/role/user/getmenus',
    method: 'get',
    baseURL: process.env.VUE_APP_BASE_API2,
    params: query
  })
}
export function roleUser(data) {
  return request({
    url: '/sys/role/user',
    method: 'post',
    baseURL: process.env.VUE_APP_BASE_API2,
    data
  })
}
